home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
bbsutil
/
bsrc_250.zip
/
SCHED.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-15
|
16KB
|
517 lines
/*--------------------------------------------------------------------------*/
/* */
/* */
/* ------------ Bit-Bucket Software, Co. */
/* \ 10001101 / Writers and Distributors of */
/* \ 011110 / Freely Available<tm> Software. */
/* \ 1011 / */
/* ------ */
/* */
/* (C) Copyright 1987-91, Bit Bucket Software Co., a Delaware Corporation. */
/* */
/* */
/* This module was originally written by Bob Hartman */
/* */
/* */
/* BinkleyTerm Scheduler Routines */
/* */
/* */
/* For complete details of the licensing restrictions, please refer */
/* to the License agreement, which is published in its entirety in */
/* the MAKEFILE and BT.C, and also contained in the file LICENSE.250. */
/* */
/* USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE */
/* BINKLEYTERM LICENSING AGREEMENT. IF YOU DO NOT FIND THE TEXT OF */
/* THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO */
/* NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT BIT BUCKET */
/* SOFTWARE CO. AT ONE OF THE ADDRESSES LISTED BELOW. IN NO EVENT */
/* SHOULD YOU PROCEED TO USE THIS FILE WITHOUT HAVING ACCEPTED THE */
/* TERMS OF THE BINKLEYTERM LICENSING AGREEMENT, OR SUCH OTHER */
/* AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO. */
/* */
/* */
/* You can contact Bit Bucket Software Co. at any one of the following */
/* addresses: */
/* */
/* Bit Bucket Software Co. FidoNet 1:104/501, 1:343/491 */
/* P.O. Box 460398 AlterNet 7:491/0 */
/* Aurora, CO 80046 BBS-Net 86:2030/1 */
/* Internet f491.n343.z1.fidonet.org */
/* */
/* Please feel free to contact us at any time to share your comments about */
/* our software and/or licensing policies. */
/* */
/*--------------------------------------------------------------------------*/
/* Include this file before any other includes or defines! */
#include "includes.h"
/**************************************************************************/
/*** This MUST be exactly 16 total bytes including the terminating null ***/
/*** or the routines read_sched() and write_sched() must be changed!!!! ***/
/**************************************************************************/
static char *BinkSched = PRDCT_SHRT "Schedule 08"; /* Version of scheduler */
void find_event ()
{
time_t long_time;
struct tm *tm;
int cur_day;
int our_time;
int i;
char cmds[150];
BINK_EVENT evt;
/* Get the current time into a structure */
(void) time (&long_time);
tm = localtime (&long_time);
cur_day = 1 << tm->tm_wday;
our_time = (tm->tm_hour % 24) * 60 + (tm->tm_min % 60);
cur_event = -1;
if (tm->tm_mday != hist.which_day)
{
write_stats ();
(void) memset (&hist, 0, sizeof (HISTORY));
hist.which_day = tm->tm_mday;
if (un_attended && fullscreen)
{
do_today ();
sb_show ();
}
}
/* Make the month 1-based instead of 0-based */
tm->tm_mon += 1;
/* Go through the events from top to bottom */
for (i = 0; i < num_events; i++)
{
if (our_time >= e_ptrs[i].minute)
{
evt = e_ptrs[i];
if ((cur_day & evt.days) &&
((!evt.day) || (evt.day == (char)tm->tm_mday)) &&
((!evt.month) || (evt.month == (char)tm->tm_mon)))
{
if (((our_time - evt.minute) < evt.length) ||
((our_time == evt.minute) && (evt.length == 0)) ||
((evt.behavior & MAT_FORCED) && (evt.last_ran != (char)tm->tm_mday)))
{
/* Are we not supposed to force old events */
if (((our_time - evt.minute) > evt.length) && (noforce))
{
e_ptrs[i].last_ran = (char) tm->tm_mday;
continue;
}
if (evt.last_ran != (char) tm->tm_mday)
{
cur_event = i;
do_ready (MSG_TXT(M_READY_WAITING));
status_line (MSG_TXT(M_STARTING_EVENT), i + 1);
if (!blank_on_key)
screen_blank = 0;
more_mail = 1;
/* Mark that this one is running */
e_ptrs[i].last_ran = (char) tm->tm_mday;
/*
* Mark that we have not yet skipped it. After all, it just
* started!
*/
e_ptrs[i].behavior &= ~MAT_SKIP;
/* Write out the schedule */
write_sched ();
/* If we are supposed to exit, then do it */
if (evt.errlevel[0])
{
status_line (MSG_TXT(M_EVENT_EXIT), evt.errlevel[0]);
screen_blank = 0;
errl_exit (evt.errlevel[0]);
}
else if (packer != NULL)
{
if (!blank_on_key)
screen_blank = 0;
status_line (MSG_TXT(M_CLEAN_PACK));
mdm_init (modem_busy);
exit_DTR ();
screen_clear ();
vfossil_cursor (1);
if (cleanup != NULL)
{
(void) strcpy (cmds, cleanup);
if (i >= 0)
(void) strcat (cmds, evt.cmd);
b_spawn (cmds);
}
(void) strcpy (cmds, packer);
if (i >= 0)
(void) strcat (cmds, evt.cmd);
b_spawn (cmds);
if (fullscreen)
{
screen_clear ();
sb_dirty ();
opening_banner ();
mailer_banner ();
}
RAISE_DTR ();
mdm_init (modem_init);
status_line (MSG_TXT(M_AFTER_CLEAN_PACK));
waitfor_line = timerset ((unsigned int)6000);
}
cur_event = i;
max_connects = evt.with_connect;
max_noconnects = evt.no_connect;